# -*- coding: utf-8 -*-
"""
Created on Thu Nov  8 20:41:09 2018

@author: 陈忠涛
"""

import numpy as np
from scipy.cluster.vq import vq, kmeans, whiten

from sklearn.cluster import KMeans

# k-均值
list1 = [88.0, 74.0, 96.0, 85.0]
list2 = [92.0, 99.0, 95.0, 94.0]
list3 = [91.0, 87.0, 99.0, 95.0]
list4 = [78.0, 99.0, 97.0, 81.0]
list5 = [88.0, 78.0, 98.0, 84.0]
list6 = [100.0, 95.0, 100.0, 92.0]

data = np.array([list1,list2,list3,list4,list5,list6])
w = whiten(data)
c,_ = kmeans(w,2)
result,_ = vq(w,c)
print('K-均值算法：',result)

# Scikit-learn
data_s = np.array([list1,list2,list3,list4,list5,list6])
kmeans = KMeans(n_clusters = 2).fit(data_s)
pred = kmeans.predict(data_s)
print('Scikit-learn：',pred)